import request from '../utils/request'
import API from './constants'

/**
 * 分页查询 列表数据
 */
export const getList = ({
  page = 1,
  pageSize = 10,
} = {}) =>
  request({
    url: API.HEALTH_API,
    method: 'GET',
    params: {
      page,
      pageSize,
    },
  })

// 查询所有数据
export const getAll = () =>
  request({
    url: API.HEALTH_API,
    method: 'GET',
    params: {
      action: 'all',
    },
  })

/**
 * 添加健康数据
 * @param {*} info 数据项信息
 */
export const add = (info) =>
  request({
    url: API.HEALTH_API,
    method: 'POST',
    data: info,
  })

/**
 * 修改健康数据
 * @param {*} info 数据项信息
 */
export const update = (info) =>
  request({
    url: API.HEALTH_API + '/' + info.id,
    method: 'PUT',
    data: info,
  })

export const remove = (id) =>
  request({
    url: API.HEALTH_API + '/' + id,
    method: 'DELETE',
  })
